home *** CD-ROM | disk | FTP | other *** search
- import hhapplet.AboutDialogBox;
- import hhapplet.ButtonLauncher;
- import hhapplet.ButtonPushEvent;
- import hhapplet.ButtonPushEventListener;
- import hhapplet.DialogDoneTarget;
- import hhapplet.IndexPane;
- import hhapplet.IndexSecondaryDialog;
- import hhapplet.IndexSecondaryEntry;
- import hhapplet.LabelLauncher;
- import hhapplet.PopupMenu;
- import hhapplet.SiteMapParserToContents;
- import hhapplet.SiteMapParserToIndex;
- import hhapplet.SplashScreen;
- import hhapplet.TabButton;
- import hhapplet.TabPanel;
- import hhapplet.URLFileHandler;
- import java.applet.Applet;
- import java.awt.BorderLayout;
- import java.awt.CardLayout;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Image;
- import java.awt.Label;
- import java.awt.LayoutManager;
- import java.awt.Panel;
- import java.awt.Rectangle;
- import java.awt.Window;
- import java.io.IOException;
- import java.io.InputStream;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.Vector;
- import sitemap.SiteMapParser;
- import treeview.TreeViewImageSet;
-
- public class WebHelp extends Applet implements ButtonPushEventListener {
- private static final String STR_APPLET_ID = "WebHelp Applet Version 1.01.121";
- private static final String STR_COPYRIGHT = "Copyright (c) 1998 Blue Sky Software Corp. All rights reserved.";
- private Window m_winFrameToShow;
- private String m_strContentsFile;
- private String m_strIndexFile;
- private String m_strHelpFile;
- private boolean m_bContentsLoaded;
- private boolean m_bIndexLoaded;
- private boolean m_bHelpLoaded;
- private String m_strCurrentCommand;
- private Panel m_pnlNav;
- private TabPanel m_pnlTabs;
- private CardLayout m_clLayout;
- private boolean m_bParsing;
- private Image[] m_imgList;
- private TreeViewImageSet m_tvisImages;
- private SiteMapParser m_smpContents;
- private SiteMapParser m_smpIndex;
- private SiteMapParser m_smpHelp;
- private IndexPane m_ipIndex;
- private Thread parser_thread;
- private TabButton m_tbtnToc;
- private TabButton m_tbtnIndex;
- private TabButton m_tbtnHelp;
- private boolean m_bMustHaveSize;
- private boolean m_bIsIE3;
- private long m_lnTimeCreated = System.currentTimeMillis();
-
- public void stop() {
- if (this.m_winFrameToShow != null) {
- this.m_winFrameToShow.hide();
- }
-
- }
-
- public void notifyButtonPushEvent(ButtonPushEvent var1) {
- if (var1.getSource() == this.m_tbtnToc) {
- this.m_tbtnToc.disable();
- this.m_tbtnIndex.enable();
- if (this.m_tbtnHelp != null) {
- this.m_tbtnHelp.enable();
- }
-
- this.DoContents(this.m_strContentsFile);
- ((Component)this).repaint();
- } else if (var1.getSource() == this.m_tbtnIndex) {
- this.m_tbtnIndex.disable();
- this.m_tbtnToc.enable();
- if (this.m_tbtnHelp != null) {
- this.m_tbtnHelp.enable();
- }
-
- this.DoIndex(this.m_strIndexFile);
- ((Component)this).repaint();
- } else {
- if (this.m_tbtnHelp != null && var1.getSource() == this.m_tbtnHelp) {
- this.m_tbtnIndex.enable();
- this.m_tbtnToc.enable();
- this.m_tbtnHelp.disable();
- this.DoHelp(this.m_strHelpFile);
- ((Component)this).repaint();
- }
-
- }
- }
-
- private void DoBadCommand(String var1) {
- ((Container)this).add(new Label("The command \"" + var1 + "\" is unrecognised"));
- }
-
- private void DoNavPane() {
- ((Component)this).setBackground(new Color(192, 192, 192));
- ((Container)this).setLayout(new BorderLayout());
- this.m_strContentsFile = ((Applet)this).getParameter("ContentsFile");
- this.m_strIndexFile = ((Applet)this).getParameter("IndexFile");
- this.m_strHelpFile = ((Applet)this).getParameter("HelpFile");
- String var1 = ((Applet)this).getParameter("ContentsTab");
- if (var1 == null) {
- var1 = "Contents";
- }
-
- String var2 = ((Applet)this).getParameter("IndexTab");
- if (var2 == null) {
- var2 = "Index";
- }
-
- String var3 = null;
- if (this.m_strHelpFile != null) {
- var3 = ((Applet)this).getParameter("HelpTab");
- if (var3 == null) {
- var3 = "Help";
- }
- }
-
- this.m_pnlTabs = null;
- this.m_pnlTabs = new TabPanel();
- this.m_pnlTabs.setBackground(((Component)this).getBackground());
- this.m_pnlTabs.setLayout((LayoutManager)null);
- this.m_tbtnToc = new TabButton(var1);
- this.m_tbtnToc.addButtonPushEventListener(this);
- this.m_tbtnIndex = new TabButton(var2);
- this.m_tbtnIndex.addButtonPushEventListener(this);
- this.m_pnlTabs.add(this.m_tbtnToc);
- this.m_pnlTabs.add(this.m_tbtnIndex);
- if (this.m_strHelpFile != null) {
- this.m_tbtnHelp = new TabButton(var3);
- this.m_tbtnHelp.addButtonPushEventListener(this);
- this.m_pnlTabs.add(this.m_tbtnHelp);
- }
-
- ((Container)this).add("North", this.m_pnlTabs);
- Rectangle var4 = ((Component)this).bounds();
- this.rods_reshape(this.m_tbtnToc, 1, var4.y, this.m_tbtnToc.preferredSize().width, 25);
- this.rods_reshape(this.m_tbtnIndex, 1 + this.m_tbtnToc.bounds().width, var4.y, this.m_tbtnIndex.preferredSize().width, 25);
- if (this.m_tbtnHelp != null) {
- this.rods_reshape(this.m_tbtnHelp, 1 + this.m_tbtnToc.bounds().width + this.m_tbtnIndex.bounds().width, var4.y, this.m_tbtnHelp.preferredSize().width, 25);
- }
-
- this.rods_reshape(this.m_pnlTabs, var4.x, var4.y, var4.width, 28);
- this.m_pnlTabs.requestFocus();
- this.m_tbtnIndex.enable();
- this.m_tbtnToc.enable();
- if (this.m_tbtnHelp != null) {
- this.m_tbtnHelp.enable();
- }
-
- this.m_tbtnToc.disable();
- this.m_tbtnIndex.disable();
- if (this.m_tbtnHelp != null) {
- this.m_tbtnHelp.disable();
- }
-
- boolean var5 = true;
- String var6 = ((Applet)this).getParameter("CurrentTab");
- if (var6 != null && var6.equalsIgnoreCase("Index")) {
- var5 = false;
- }
-
- Object var7 = null;
- ButtonPushEvent var11;
- if (var5) {
- var11 = new ButtonPushEvent(this.m_tbtnToc, 0, 0);
- } else {
- var11 = new ButtonPushEvent(this.m_tbtnIndex, 0, 0);
- }
-
- this.notifyButtonPushEvent(var11);
-
- try {
- String var8 = System.getProperty("java.vendor");
- if (var8.startsWith("Netscape")) {
- Panel var9 = new Panel();
- ((Container)var9).setLayout((LayoutManager)null);
- ((Component)var9).resize(((Component)this).bounds().width, 14);
- ((Container)this).add("South", var9);
- return;
- }
- } catch (Exception var10) {
- }
-
- }
-
- public void Command(String var1, String var2) {
- if (var1 != null) {
- if (var1.equalsIgnoreCase("Contents")) {
- this.DoContents(var2);
- } else if (var1.equalsIgnoreCase("Index")) {
- this.DoIndex(var2);
- } else if (var1.equalsIgnoreCase("Version")) {
- this.ShowVersion();
- } else {
- this.DoBadCommand("Command method does not support " + var1);
- }
- }
- }
-
- public void destroy() {
- if (this.m_winFrameToShow != null) {
- this.m_winFrameToShow.hide();
- this.m_winFrameToShow.dispose();
- this.m_winFrameToShow = null;
- }
-
- if (this.m_smpContents != null) {
- this.m_smpContents.closeFiles();
- }
-
- if (this.m_smpIndex != null) {
- this.m_smpIndex.closeFiles();
- }
-
- if (this.m_smpHelp != null) {
- this.m_smpHelp.closeFiles();
- }
-
- if (this.m_ipIndex != null && this.m_ipIndex.getList() != null) {
- this.m_ipIndex.getList().clear();
- }
-
- if (this.m_tvisImages != null) {
- this.m_tvisImages.releaseImages(this.m_imgList);
- }
-
- if (this.parser_thread != null && this.parser_thread.isAlive()) {
- this.parser_thread.stop();
- this.parser_thread = null;
- }
-
- }
-
- protected void rods_reshape(Component var1, int var2, int var3, int var4, int var5) {
- var1.move(var2, var3);
- var1.resize(var4, var5);
- }
-
- private void DoContents(String var1) {
- if (var1 == null) {
- ((Container)this).setLayout(new BorderLayout());
- }
-
- if (this.m_pnlNav == null) {
- this.m_clLayout = new CardLayout();
- this.m_pnlNav = new Panel();
- this.m_pnlNav.setLayout(this.m_clLayout);
- ((Container)this).add("Center", this.m_pnlNav);
- }
-
- if (this.m_tvisImages == null) {
- this.m_tvisImages = new TreeViewImageSet();
- this.m_imgList = new Image[14];
- this.m_imgList = this.m_tvisImages.reallyGetImages();
- }
-
- if (var1 == null) {
- var1 = ((Applet)this).getParameter("Item1");
- }
-
- if (this.m_bContentsLoaded && this.m_strContentsFile != null && this.m_strContentsFile.equals(var1)) {
- this.m_clLayout.show(this.m_pnlNav, "Contents");
- } else {
- this.m_strContentsFile = var1;
- this.m_bContentsLoaded = true;
- this.m_bMustHaveSize = true;
-
- try {
- URL var2 = URLFileHandler.makeURL(((Applet)this).getDocumentBase(), var1, (String)null);
- InputStream var3 = var2.openStream();
- SiteMapParserToContents var4 = new SiteMapParserToContents(this, this.m_imgList);
- if (this.m_smpContents != null) {
- this.m_smpContents.closeFiles();
- }
-
- this.m_smpContents = new SiteMapParser(var3, var4);
- ((Applet)this).showStatus("Loading Table of Contents...");
- this.m_pnlNav.add("Contents", var4.getTree());
- this.m_clLayout.show(this.m_pnlNav, "Contents");
- var4.getTree().requestFocus();
- this.parser_thread = this.m_smpContents.parseInSeparateThread();
- ((Component)this).repaint();
- ((Component)this).show();
- var4.getTree().requestFocus();
- } catch (IOException var6) {
- ((Container)this).add("Center", new Label("Can't open URL or file " + ((Throwable)var6).getMessage()));
- }
- }
- }
-
- private void DoHHVersion(boolean var1) {
- String var2 = null;
- Object var3 = null;
- String var4 = null;
- if (!var1) {
- var2 = ((Applet)this).getParameter("Button");
- String var12 = ((Applet)this).getParameter("Text");
- if (var2 == null && var12 == null) {
- return;
- }
-
- var4 = var2 != null ? var2 : var12;
- }
-
- Vector var5 = new Vector();
- var5.addElement("WebHelp Applet Version 1.01.121");
- var5.addElement("Copyright (c) 1998 Blue Sky Software Corp. All rights reserved.");
-
- try {
- var5.addElement("Java VM vendor: " + System.getProperty("java.vendor"));
- } catch (Exception var11) {
- }
-
- try {
- var5.addElement("Java version: " + System.getProperty("java.version"));
- } catch (Exception var10) {
- }
-
- try {
- var5.addElement("Java library version: " + System.getProperty("java.class.version"));
- } catch (Exception var9) {
- }
-
- try {
- String var6 = "Operating System: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " (" + System.getProperty("os.arch") + ")";
- var5.addElement(var6);
- } catch (Exception var8) {
- }
-
- AboutDialogBox var13 = new AboutDialogBox("About WebHelp Applet", var5);
- if (var1) {
- var13.show();
- } else {
- Component var7 = var2 != null ? (Component)(new ButtonLauncher(var4, var13)) : (Component)(new LabelLauncher(var4, var13));
- ((Container)this).setLayout(new BorderLayout());
- ((Container)this).add("Center", var7);
- this.m_winFrameToShow = var13;
- }
- }
-
- public synchronized void resize(int var1, int var2) {
- super.resize(var1, var2);
- }
-
- public synchronized boolean checkSize() {
- if (((Component)this).bounds().width == 0 && ((Component)this).bounds().height == 0) {
- String var1 = ((Applet)this).getDocumentBase().toString();
- int var2 = var1.lastIndexOf(".");
- String var3 = var1.substring(var2, var1.length());
- var1 = var1.substring(0, var2);
- var1 = var1 + "f" + var3;
-
- try {
- URL var4 = new URL(var1);
- ((Applet)this).getAppletContext().showDocument(var4, "_self");
- return false;
- } catch (Exception var5) {
- }
- }
-
- return true;
- }
-
- private void DoSplash() {
- ((Applet)this).showStatus("Loading Splash Image...");
-
- try {
- Object var1 = null;
- Object var2 = null;
-
- try {
- var13 = ((Applet)this).getImage(URLFileHandler.makeURL(((Applet)this).getDocumentBase(), ((Applet)this).getParameter("Item1"), (String)null));
- } finally {
- ;
- }
-
- int var3 = 2500;
-
- try {
- var3 = new Integer(((Applet)this).getParameter("Item2"));
- } catch (NumberFormatException var10) {
- }
-
- SplashScreen var4 = new SplashScreen(this, var13, var3, (String)var2);
- var4.show();
- } catch (MalformedURLException var12) {
- ((Container)this).add("Center", new Label("Can't open URL or file " + ((Throwable)var12).getMessage()));
- }
- }
-
- private void DoAboutBox() {
- String var1 = ((Applet)this).getParameter("Button");
- String var2 = ((Applet)this).getParameter("Text");
- if (var1 != null || var2 != null) {
- String var3 = var1 != null ? var1 : var2;
- String var4 = ((Applet)this).getParameter("Item1");
- Vector var5 = new Vector();
-
- String var7;
- for(int var6 = 0; (var7 = ((Applet)this).getParameter("Item" + (var6 + 2))) != null; ++var6) {
- var5.addElement(var7);
- }
-
- AboutDialogBox var8 = new AboutDialogBox(var4, var5);
- Component var9 = var1 != null ? (Component)(new ButtonLauncher(var3, var8)) : (Component)(new LabelLauncher(var3, var8));
- ((Container)this).setLayout(new BorderLayout());
- ((Container)this).add("Center", var9);
- this.m_winFrameToShow = var8;
- }
- }
-
- private void DoIndex(String var1) {
- if (var1 == null) {
- ((Container)this).setLayout(new BorderLayout());
- }
-
- if (this.m_pnlNav == null) {
- this.m_clLayout = new CardLayout();
- this.m_pnlNav = new Panel();
- this.m_pnlNav.setLayout(this.m_clLayout);
- ((Container)this).add("Center", this.m_pnlNav);
- }
-
- if (var1 == null) {
- var1 = ((Applet)this).getParameter("Item1");
- }
-
- if (this.m_bIndexLoaded && this.m_strIndexFile != null && this.m_strIndexFile.equals(var1)) {
- this.m_clLayout.show(this.m_pnlNav, "Index");
- if (this.m_ipIndex != null) {
- this.m_ipIndex.requestFocus();
- }
-
- } else {
- this.m_strIndexFile = var1;
- this.m_bIndexLoaded = true;
- this.m_bMustHaveSize = true;
-
- try {
- InputStream var2 = URLFileHandler.makeURL(((Applet)this).getDocumentBase(), var1, (String)null).openStream();
- SiteMapParserToIndex var3 = new SiteMapParserToIndex(this);
- if (this.m_ipIndex != null && this.m_ipIndex.getList() != null) {
- this.m_ipIndex.getList().clear();
- }
-
- this.m_ipIndex = var3.getIndex();
- this.m_pnlNav.add("Index", this.m_ipIndex);
- this.m_clLayout.show(this.m_pnlNav, "Index");
- ((Component)this).repaint();
- ((Applet)this).showStatus("Loading Index...");
- if (this.m_smpIndex != null) {
- this.m_smpIndex.closeFiles();
- }
-
- this.m_smpIndex = new SiteMapParser(var2, var3);
- if (this.m_ipIndex != null) {
- this.m_ipIndex.requestFocus();
- }
-
- this.parser_thread = this.m_smpIndex.parseInSeparateThread();
- } catch (IOException var5) {
- ((Container)this).add("Center", new Label("Can't open URL or file " + ((Throwable)var5).getMessage()));
- }
- }
- }
-
- public void start() {
- if (this.m_bMustHaveSize) {
- this.checkSize();
- }
-
- }
-
- public String getAppletInfo() {
- return "WebHelp Applet Version 1.01.121" + "\r\n" + "Copyright (c) 1998 Blue Sky Software Corp. All rights reserved.";
- }
-
- public void Click() {
- if (this.m_winFrameToShow != null) {
- if (this.m_bIsIE3) {
- MethodRunner var1 = new MethodRunner(this.m_winFrameToShow, "ClickThread");
- ((Thread)var1).start();
- return;
- }
-
- this.m_winFrameToShow.show();
- }
-
- }
-
- private void ShowVersion() {
- this.DoHHVersion(true);
- }
-
- public static int GetFontSize() {
- byte var0 = 12;
-
- try {
- if (System.getProperty("os.name").startsWith("Windows") && !System.getProperty("java.version").equals("1.1.4")) {
- var0 = 10;
- }
-
- return var0;
- } finally {
- ;
- }
- }
-
- public static String GetFontName() {
- return "Dialog";
- }
-
- public void init() {
- this.m_lnTimeCreated = System.currentTimeMillis();
- if (System.getProperty("java.vendor").startsWith("Microsoft") && System.getProperty("java.version").startsWith("1.0")) {
- this.m_bIsIE3 = true;
- }
-
- String var1 = ((Applet)this).getParameter("Command");
- if (var1 != null) {
- if (var1.equalsIgnoreCase("Contents")) {
- this.DoContents((String)null);
- } else if (var1.equalsIgnoreCase("Index")) {
- this.DoIndex((String)null);
- } else if (var1.equalsIgnoreCase("Splash")) {
- this.DoSplash();
- } else if (var1.equalsIgnoreCase("Help")) {
- this.DoHelp((String)null);
- } else if (var1.equalsIgnoreCase("Related Topics")) {
- this.DoRelatedTopics(false);
- } else if (var1.equalsIgnoreCase("Related Topics,MENU")) {
- this.DoRelatedTopics(true);
- } else if (var1.equalsIgnoreCase("HH Version")) {
- this.DoHHVersion(false);
- } else if (var1.equalsIgnoreCase("AboutBox")) {
- this.DoAboutBox();
- } else if (var1.equalsIgnoreCase("NavPane")) {
- this.DoNavPane();
- } else {
- this.DoBadCommand(var1);
- }
-
- this.m_strCurrentCommand = var1;
- }
- }
-
- private void DoHelp(String var1) {
- if (var1 == null) {
- ((Container)this).setLayout(new BorderLayout());
- }
-
- if (this.m_pnlNav == null) {
- this.m_clLayout = new CardLayout();
- this.m_pnlNav = new Panel();
- this.m_pnlNav.setLayout(this.m_clLayout);
- ((Container)this).add("Center", this.m_pnlNav);
- }
-
- if (this.m_tvisImages == null) {
- this.m_tvisImages = new TreeViewImageSet();
- this.m_imgList = new Image[14];
- this.m_imgList = this.m_tvisImages.reallyGetImages();
- }
-
- if (var1 == null) {
- var1 = ((Applet)this).getParameter("Item1");
- }
-
- if (this.m_bHelpLoaded && this.m_strHelpFile != null && this.m_strHelpFile.equals(var1)) {
- this.m_clLayout.show(this.m_pnlNav, "Help");
- } else {
- this.m_strHelpFile = var1;
- this.m_bHelpLoaded = true;
-
- try {
- URL var2 = URLFileHandler.makeURL(((Applet)this).getDocumentBase(), var1, (String)null);
- InputStream var3 = var2.openStream();
- SiteMapParserToContents var4 = new SiteMapParserToContents(this, this.m_imgList);
- if (this.m_smpHelp != null) {
- this.m_smpHelp.closeFiles();
- }
-
- this.m_smpHelp = new SiteMapParser(var3, var4);
- ((Applet)this).showStatus("Loading Help Selections...");
- this.m_pnlNav.add("Help", var4.getTree());
- this.m_clLayout.show(this.m_pnlNav, "Help");
- ((Component)this).repaint();
- this.m_smpHelp.parse();
- } catch (IOException var6) {
- ((Container)this).add("Center", new Label("Can't open URL or file " + ((Throwable)var6).getMessage()));
- }
- }
- }
-
- private void DoRelatedTopics(boolean var1) {
- ((Applet)this).showStatus("Loading Related Topics Button...");
- String var2 = ((Applet)this).getParameter("Button");
- String var3 = ((Applet)this).getParameter("Text");
- String var4 = ((Applet)this).getParameter("Frame");
- if (var1 && System.getProperty("os.name").startsWith("SunOS")) {
- var1 = false;
- }
-
- boolean var5 = var2 == null && var3 == null;
- String var6 = "";
- if (!var5) {
- var6 = var2 != null ? var2 : var3;
- }
-
- Vector var7 = new Vector();
- int var8 = 0;
-
- while(true) {
- while(true) {
- String var9;
- if ((var9 = ((Applet)this).getParameter("Item" + (var8 + 1))) == null) {
- if (var8 == 0) {
- return;
- }
-
- if (var1) {
- PopupMenu var18 = new PopupMenu(this, var7);
- this.m_winFrameToShow = var18;
- } else {
- IndexSecondaryDialog var19 = new IndexSecondaryDialog(this, var7, (DialogDoneTarget)null);
- this.m_winFrameToShow = var19;
- }
-
- if (!var5) {
- Component var17;
- if (var2 != null) {
- var17 = (Component)(new ButtonLauncher(var6, this.m_winFrameToShow));
- } else {
- var17 = (Component)(new LabelLauncher(var6, this.m_winFrameToShow));
- }
-
- ((Container)this).setLayout(new BorderLayout());
- ((Container)this).add("Center", var17);
- }
-
- return;
- }
-
- try {
- IndexSecondaryEntry var10 = new IndexSecondaryEntry();
- int var11 = var9.indexOf(59);
- if (var11 != -1 && var11 != var9.length() - 1) {
- int var12 = var9.indexOf(59, var11 + 1);
- String var13 = var9.substring(0, var11);
- String var14 = var12 == -1 ? var9.substring(var11 + 1) : var9.substring(var11 + 1, var12);
- String var15 = var12 == -1 ? null : var9.substring(var11 + 1);
- var10.name = var13;
- var10.local = var14;
- var10.url = var15;
- var10.frame = var4;
- var7.addElement(var10);
- break;
- }
- } catch (MalformedURLException var16) {
- break;
- }
- }
-
- ++var8;
- }
- }
-
- public synchronized void reshape(int var1, int var2, int var3, int var4) {
- super.reshape(var1, var2, var3, var4);
- }
- }
-